/**
 * �ͻ��˺ͷ������˱���ͨ�ŵ��߳�
 * ���ϵض�ȡ����������������
 */
package com.shgsh.server.client;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import com.shgsh.server.message.Message;
import com.shgsh.server.model.IMMessage;


public class ClientConServerThread extends Thread implements ClientThread{
    private String id;
    private  Socket s;
    public Socket getS() {return s;}
    public ClientConServerThread(String id,Socket s){
        this.id=id;
        this.s=s;
    }

    @Override
    public void run() {
        while(true){
            ObjectInputStream ois = null;
            ObjectOutputStream oos =  null;
            Message m;
            try {
                oos = new ObjectOutputStream(s.getOutputStream());
                IMMessage message = new IMMessage();
                message.setId("1");
                message.setReceiverId("2");
                message.setSendId("1");
                message.setContent("hello");
                message.setSendTime("00:00:00");
                oos.writeObject(message);

                ois = new ObjectInputStream(s.getInputStream());
                m=(Message) ois.readObject();
                System.out.println("m = " + m);
            } catch (Exception e) {
                //e.printStackTrace();
                try {
                    if(s!=null){
                        s.close();
                    }
                } catch (IOException e1) {
                    //e1.printStackTrace();
                }
            }
        }
    }

}
